package com.jswdwsx.esign.protocol

import com.jswdwsx.esign.commom.ResEnum
import com.jswdwsx.esign.exception.EsignBusinessException

data class EsignResp<T>(
    var code: String = "0",
    var message: String? = "",
    var data: T? = null
) {
    val isSuccess: Boolean
        get() = this.code == "0"

    // 如果data为空就 抛出以传入信息构造的异常
    fun data(exceptionEnum: ResEnum): T {
        return data ?: throw EsignBusinessException(exceptionEnum, message)
    }
}